﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ThucThe;
using DieuKhien;

namespace GiaoDien
{
    public partial class QL_DiaDanh_sua : Form
    {
        DiaDanh_thucthe dd_tt = new DiaDanh_thucthe();
        DiaDanh_dieukhien dd_dk = new DiaDanh_dieukhien();
        QL frm_ql = new QL();
        public QL_DiaDanh_sua()
        {
            InitializeComponent();
        }
        public void loadDuLieu(DiaDanh_thucthe dd)
        {
            txt_maDiaDanh.Text = dd.MaDiaDanh.ToString();
            txt_maDiaDanh.Enabled = false;
            txt_tenDiaDanh.Text = dd.TenDiaDanh;
            txt_moTa.Text = dd.MoTa;
            txt_diaChi.Text = dd.DiaChi;
        }
        private void btn_OK_Click(object sender, EventArgs e)
        {
            try
            {
                dd_tt.MaDiaDanh = int.Parse(txt_maDiaDanh.Text.Trim());
                dd_tt.TenDiaDanh = txt_tenDiaDanh.Text.Trim();
                dd_tt.MoTa = txt_moTa.Text.Trim();
                dd_tt.DiaChi = txt_diaChi.Text.Trim();
                dd_dk.suaDiaDanh(dd_tt);
                this.Close();
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Nhập đầy đủ các trường", "Thêm địa danh");
            }
        }

        private void btn_exit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btn_reset_Click(object sender, EventArgs e)
        {
            txt_tenDiaDanh.Text = "";
            txt_moTa.Text = "";
            txt_diaChi.Text = "";
        }
    }
}
